package springframeworkcase.code.service.impl;


import cn.hutool.core.lang.UUID;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import springframeworkcase.code.entities.Payment;
import springframeworkcase.code.service.PaymentService;

import java.util.HashMap;
import java.util.Map;

/**
 * @date 2024/1/17 10:40
 **/
@Slf4j
@Service
public class PaymentServiceImpl implements PaymentService {

    /**
     * 模拟数据库
     */
    private final Map<Long, Payment> dataBase = new HashMap<>();

    /**
     * 新增
     *
     * @param payment
     * @return
     */
    @Override
    public int create(Payment payment) {
        dataBase.put(payment.getId(), payment);
        log.info("添加成功");
        return 1;
    }

    /**
     * 根据Id查询
     *
     * @param id
     * @return
     */
    @Override
    public Payment getPaymentById(Long id) {
        log.info("查询成功");
        return dataBase.get(id);
    }
}
